package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._03装饰模式._5商品价格策略工厂;

/**
 * @ClassName CashContext
 * @Description TODO
 * @Author zero
 * @DATE 2023/7/10 10:43 PM
 * @Version 1.0
 */
public class CashContext {
    private CashSuper cashSuper;
    public CashContext(int discount) {
        // 1.正常收费 2.打八折 3.打七折 4.满300送100 5.先8折，再满300送100）
        switch (discount){
            case 1:
                cashSuper = new CashNormal();
                break;
            case 2:
                cashSuper=new CashRebate(0.8);
                break;
            case 3:
                cashSuper = new CashRebate(0.7);
                break;
            case 4:
                cashSuper = new CashReturn(300,100);
                break;
            case 5:
                cashSuper = new CashReturnRebate(0.8,300,100);
                break;
        }

    }

    public double getResult(double price, int num) {
        return cashSuper.acceptCash(price,num);
    }
}
